'=============================================================================== '= Copyright 1992 Staz™ Software, Inc. = '= All rights reserved = '= "Key.FLTR" from PG:PRO = '=============================================================================== INCLUDE FILE _aplIncl COMPILE 0,_MacsbugLabels_strResource_caseInsensitive'set by PG:PRO GLOBALS "PG PRO.GLBL"'include standard global file END GLOBALS'no other globals GOTO "Key Filter:Start"'ALWAYS jump around functions INCLUDE "@Header.INCL" DEFSTR LONG'needed for CVI's _KFrepairField = 2000 _KFMMDDYY = 1'08/15/92 _KFMMYY = 2'08/92 _KFCAPS = 3'UCASE$ _KFWordCaps = 4'word caps _KFHex = 5'hexidecimal _KFIntegers = 6'0123456789- _KFDecimals = 7'0123456789.- _KFCAPSnDigits = 8'A-Z and 0-9 _KFDollars = 9'0123456789.-$ _KFCustom1 = 10'build your own(1) _KFCustom2 = 11'build your own(2) _KFCustom3 = 12'build your own(3) _KFCustom4 = 13'build your own(4) _KFCustom5 = 14'build your own(5) '_______________________________________________________________________________ LOCAL FN KFstrip$(theText$)'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑ '————————————————————————————————————————————————————————————————————————————— xtract$ = "" FOR x = 1 TO LEN(theText$) char = PEEK(@theText$+x) LONG IF char <> 32 xtract$ =xtract$ + CHR$(char) END IF NEXT END FN = xtract$ '_______________________________________________________________________________ LOCAL FN KFdateFld'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑ '————————————————————————————————————————————————————————————————————————————— TEKEY$ = gKey$:gKey$ = "" oldInsPt = WINDOW(_selStart) theDate$ = EDIT$(WINDOW(_EFnum)) theDate$ = UCASE$(theDate$) mm = 0:yy = 0:dd = 0:chop = 0 newDate$ = "" theDate$ = FN KFstrip$(theDate$) IF LEFT$(theDate$,1) = "0" THEN theDate$ = MID$(theDate$,2) SELECT PEEK(@theDate$+1) CASE _"J"'Jan/June/July LONG IF LEFT$(theDate$,2)="JA" mm=1:chop=2'jan XELSE SELECT LEFT$(theDate$,3)' CASE "JUN":mm=6:chop=3'june CASE "JUL":mm=7:chop=3'july END SELECT' END IF CASE _"F":mm=2:chop=1'Feb CASE _"M"'March/May SELECT LEFT$(theDate$,3)' CASE "MAR":mm=3:chop=3'march CASE "MAY":mm=5:chop=3'may END SELECT' CASE _"A"'April/Aug SELECT LEFT$(theDate$,2)' CASE "AP":mm=4:chop=2'april CASE "AU":mm=8:chop=2'aug END SELECT' CASE _"S":mm=9 :chop=1'Sept CASE _"O":mm=10:chop=1'Oct CASE _"N":mm=11:chop=1'Nov CASE _"D":mm=12:chop=1'dec CASE _"1"'jan,oct,nov,dec LONG IF LEN(theDate$)>1 SELECT PEEK(@theDate$+2)' CASE _"0":mm=10:chop=2'oct CASE _"1":mm=11:chop=2'nov CASE _"2":mm=12:chop=2'dec CASE ELSE:mm=1:chop=1 END SELECT' XELSE theDate$ = ""'can't figure yet END IF CASE _"2":mm=2:chop=1'feb CASE _"3":mm=3:chop=1'mar CASE _"4":mm=4:chop=1'apr CASE _"5":mm=5:chop=1'may CASE _"6":mm=6:chop=1'jun CASE _"7":mm=7:chop=1'jul CASE _"8":mm=8:chop=1'aug CASE _"9":mm=9:chop=1'sept END SELECT LONG IF mm newDate$ = "0"+MID$(STR$(mm),2)+"/" newDate$ = RIGHT$(newDate$,3) theDate$ = MID$(theDate$,chop+1) chop = 0 END IF DO flag = _zTrue LONG IF LEN(theDate$) LONG IF PEEK(@theDate$+1)<_"1" OR PEEK(@theDate$+1)>_"9" theDate$ = MID$(theDate$,2) flag = _false END IF END IF UNTIL flag IF theDate$ = "" THEN "Date Key Done" SELECT PEEK(@theDate$+1) CASE > _"3" dd = PEEK(@theDate$+1)-48 theDate$ = MID$(theDate$,2) CASE ELSE LONG IF LEN(theDate$)>1 dd = VAL(theDate$) DO flag = _zTrue LONG IF LEN(theDate$) LONG IF PEEK(@theDate$+1)=>_"1" AND PEEK(@theDate$+1)<=_"9" theDate$ = MID$(theDate$,2) flag = _false END IF END IF UNTIL flag XELSE newDate$ = newDate$ + theDate$ theDate$ = "" END IF END SELECT LONG IF dd SELECT mm CASE 9,4,6,11 IF dd > 30 THEN dd = 30 CASE 2 IF dd > 29 THEN dd = 29 CASE ELSE IF dd > 31 THEN dd = 31 END SELECT t$ = "0"+MID$(STR$(dd),2)+"/" newDate$ = newDate$ + RIGHT$(t$,3) END IF LONG IF LEN(newDate$) DO flag = _zTrue LONG IF LEN(theDate$) LONG IF PEEK(@theDate$+1)<_"1" OR PEEK(@theDate$+1)>_"9" theDate$ = MID$(theDate$,2) flag = _false END IF END IF UNTIL flag yy = VAL(theDate$) LONG IF yy t$ = MID$(STR$(yy),2) IF LEN(t$)>2 THEN t$ = RIGHT$(t$,2) newDate$ = newDate$ + t$ END IF END IF "Date Key Done" LONG IF LEN(newDate$) EDIT$(WINDOW(_EFnum)) = newDate$ SETSELECT WINDOW(_EFTextLen),WINDOW(_EFTextLen) END IF END FN '_______________________________________________________________________________ LOCAL FN KFmonthFld'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑ '————————————————————————————————————————————————————————————————————————————— TEKEY$ = gKey$:gKey$ = "" theDate$ = EDIT$(WINDOW(_EFnum)) theDate$ = UCASE$(theDate$) mm = 0:yy = 0:dd = 0:chop = 0 newDate$ = "" theDate$ = FN KFstrip$(theDate$) IF LEFT$(theDate$,1) = "0" THEN theDate$ = MID$(theDate$,2) SELECT PEEK(@theDate$+1) CASE _"J"'Jan/June/July LONG IF LEFT$(theDate$,2)="JA" mm=1:chop=2'jan XELSE SELECT LEFT$(theDate$,3)' CASE "JUN":mm=6:chop=3'june CASE "JUL":mm=7:chop=3'july END SELECT' END IF CASE _"F":mm=2:chop=1'Feb CASE _"M"'March/May SELECT LEFT$(theDate$,3)' CASE "MAR":mm=3:chop=3'march CASE "MAY":mm=5:chop=3'may END SELECT' CASE _"A"'April/Aug SELECT LEFT$(theDate$,2)' CASE "AP":mm=4:chop=2'april CASE "AU":mm=8:chop=2'aug END SELECT' CASE _"S":mm=9 :chop=1'Sept CASE _"O":mm=10:chop=1'Oct CASE _"N":mm=11:chop=1'Nov CASE _"D":mm=12:chop=1'dec CASE _"1"'jan,oct,nov,dec LONG IF LEN(theDate$)>1 SELECT PEEK(@theDate$+2)' CASE _"0":mm=10:chop=2'oct CASE _"1":mm=11:chop=2'nov CASE _"2":mm=12:chop=2'dec CASE ELSE:mm=1:chop=1 END SELECT' XELSE theDate$ = ""'can't figure yet END IF CASE _"2":mm=2:chop=1'feb CASE _"3":mm=3:chop=1'mar CASE _"4":mm=4:chop=1'apr CASE _"5":mm=5:chop=1'may CASE _"6":mm=6:chop=1'jun CASE _"7":mm=7:chop=1'jul CASE _"8":mm=8:chop=1'aug CASE _"9":mm=9:chop=1'sept END SELECT LONG IF mm newDate$ = "0"+MID$(STR$(mm),2)+"/" newDate$ = RIGHT$(newDate$,3) theDate$ = MID$(theDate$,chop+1) chop = 0 END IF IF theDate$ = "" THEN "Expire Key Done" DO flag = _zTrue LONG IF LEN(theDate$) LONG IF PEEK(@theDate$+1)<_"1" OR PEEK(@theDate$+1)>_"9" theDate$ = MID$(theDate$,2) flag = _false END IF END IF UNTIL flag IF theDate$ = "" THEN "Expire Key Done" LONG IF LEN(newDate$) DO flag = _zTrue LONG IF LEN(theDate$) LONG IF PEEK(@theDate$+1)<_"1" OR PEEK(@theDate$+1)>_"9" theDate$ = MID$(theDate$,2) flag = _false END IF END IF UNTIL flag yy = VAL(theDate$) LONG IF yy t$ = MID$(STR$(yy),2) IF LEN(t$)>2 THEN t$ = RIGHT$(t$,2) newDate$ = newDate$ + t$ END IF END IF "Expire Key Done" LONG IF LEN(newDate$) EDIT$(WINDOW(_EFnum)) = newDate$ SETSELECT WINDOW(_EFTextLen),WINDOW(_EFTextLen) END IF END FN '_______________________________________________________________________________ LOCAL FN KFexitFld'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑ '————————————————————————————————————————————————————————————————————————————— thefld = WINDOW(_EFnum) theClass = WINDOW(_EFClass)>>2 SELECT theClass CASE _KFDollars:'currency text field t$ = EDIT$(thefld) xtract$ = "" IF ASC(t$) = _"(" THEN negate = _zTrue ELSE negate = _false FOR x = 1 TO LEN(t$) char = PEEK(@t$+x) LONG IF (char > 47 AND char < 58) OR char = _"." OR char = _"-" xtract$ = xtract$ + CHR$(char) END IF NEXT amnt! = VAL(xtract$) + 0. t$ = USING "###,###,###.##";(amnt!) WHILE LEFT$(t$,1) = " " OR LEFT$(t$,1) = "," t$ = MID$(t$,2) WEND t$ = "$" + t$ LONG IF amnt! < 0 OR negate = _zTrue t$ = "(" + t$ + ")" EDIT FIELD thefld, t$ EDIT TEXT ,,,,-1,0,0 XELSE EDIT TEXT ,,,,0,0,0 EDIT$(thefld) = t$ END IF CASE _KFCAPS'UCASE$ CASE _KFWordCaps'word caps CASE _KFHex'hexidecimal CASE _KFMMDDYY'MM/DD/YY t$ = gKey$ gKey$ = "" FN KFdateFld gKey$ = t$ CASE _KFIntegers'0-9 and minus (-) CASE _KFDecimals'0123456789.- CASE _KFMMYY'month & year exp date CASE _KFCAPSnDigits'A-Z 0-9 Caps only CASE _KFCustom1 CASE _KFCustom2 CASE _KFCustom3 CASE _KFCustom4 CASE _KFCustom5 END SELECT END FN '_______________________________________________________________________________ LOCAL FN KFfilterKey'∑∑œœœœœœœœœœœœœœœœœœœœœœœœœ∑∑ '————————————————————————————————————————————————————————————————————————————— key = PEEK(@gKey$+1) LONG IF key > 31 AND key < 127'don't mess w/ arrows,del,rtn theClass = WINDOW(_EFClass)>>2 SELECT theClass CASE _KFDollars:'currency text field LONG IF INSTR(1,"$-.0123456789()",gKey$) = 0 gKey$ = "" END IF :'-------------------------- CASE _KFCAPS'capitals only gKey$ = UCASE$(gKey$) :'-------------------------- CASE _KFWordCaps'word caps LONG IF WINDOW(_selStart) = 0 gKey$ = UCASE$(gKey$) XELSE prevChar = PEEK([FN TEGETTEXT(WINDOW(_EFHandle))]+WINDOW(_selStart)-1) IF prevChar = 32 THEN gKey$ = UCASE$(gKey$) END IF :'-------------------------- CASE _KFHex'hexidecimal gKey$ = UCASE$(gKey$) LONG IF INSTR(1,"$&0123456789ABCDEF",gKey$) = 0 gKey$ = "" END IF :'-------------------------- CASE _KFMMDDYY'MM/DD/YY FN KFdateFld :'-------------------------- CASE _KFIntegers'0-9 and minus (-) LONG IF INSTR(1,"0123456789-",gKey$) = 0 gKey$ = "" END IF :'-------------------------- CASE _KFDecimals'0123456789.- LONG IF INSTR(1,"0123456789.-",gKey$) = 0 gKey$ = "" END IF :'-------------------------- CASE _KFMMYY'month & year exp date FN KFmonthFld :'-------------------------- CASE _KFCAPSnDigits'A-Z 0-9 Caps only gKey$ = UCASE$(gKey$) LONG IF INSTR(1,"0123456789",gKey$) = 0 LONG IF PEEK(@gKey$+1)<_"A" OR PEEK(@gKey$+1)>_"Z" gKey$ = "" END IF END IF :'-------------------------- CASE _KFCustom1 CASE _KFCustom2 CASE _KFCustom3 CASE _KFCustom4 CASE _KFCustom5 END SELECT END IF END FN '=============================================================================== '›››››››››› FIELD FILTER ›››››››››› '=============================================================================== "Key Filter:Start" SELECT gAction CASE _mouseAction CASE _fieldAction SELECT gSubAction CASE _fieldActivate EDIT FIELD gFieldWas:FN KFexitFld EDIT FIELD gWhichField CASE _fieldChanging :DIALOG = _KFrepairField CASE _fieldKeyPressed :FN KFfilterKey CASE _fieldReturn :FN KFexitFld CASE _fieldTab :FN KFexitFld CASE _fieldShiftTab :FN KFexitFld CASE _fieldClear CASE _fieldLeft :FN KFexitFld CASE _fieldRight :FN KFexitFld CASE _fieldUp :FN KFexitFld CASE _fieldDown :FN KFexitFld CASE _fieldClicked END SELECT CASE _otherAction LONG IF gSubAction = _otherUser LONG IF gDialogValue = _KFrepairField FN KFexitFld END IF END IF END SELECT '-------------------------------------------------------------------------------